<?php
/**
 * Organizations Model for RoomBooking Component
 * 
 * @version    1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license	   GNU/GPL
 */
 
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
 
jimport( 'joomla.application.component.model' );
 
class RoomBookingModelCosts extends JModel
{
    /**
     * Organizations data array
     *
     * @var array
     */
    var $_data;
 
    /**
     * Returns the query
     * @return string The query to be used to retrieve the rows from the database
     */
    function _buildQuery()
    {
        $query = ' SELECT c.id,u.name,c.month,c.cost,c.id_user,c.charge,c.year  FROM #__roombooking_costs AS c LEFT JOIN #__users AS u ON c.id_user = u.id ORDER BY id';
        return $query;
    }
 
    /**
     * Retrieves the organization data
     * @return array Array of objects containing the data from the database
     */
    function getData()
    {
        // Lets load the data if it doesn't already exist
        if (empty( $this->_data ))
        {
            $query = $this->_buildQuery();
            $this->_data = $this->_getList( $query );
        }
 
        return $this->_data;
    }
}
